#pragma once

#define PICKING_ACCURACY 1
#define PICKING_BUFFSIZE 25
#define ORTHO_MATRIX_DEPTH 10
#define VIEWPORT_WIDTH 1280
#define VIEWPORT_HEIGHT 720
#define FULLSCREEN 1
#define SKIN_DIR "skin1"
#define NO_MOUSE_TRACE 1

#ifdef UNDER_CE
#define DATABASE_PATHNAME "\\NAND\\database\\cus.db"
#else
#define DATABASE_PATHNAME ".\\database\\cus.db"
#endif

#ifndef DEBUG
#define DEBUG 1
#endif

#ifndef AUTOSET
#define AUTOSET 0
#endif /* AUTOSET */

#ifndef TTF_GBK2UTF8
// #define TTF_GBK2UTF8
#endif


#define INVALID_TEXTURE ((GLuint)(-1))



// SDL environment variables

typedef enum
{
    T_BASE,         // 基类, 仅VBase
    T_WIDGET,       // 可视化组件
    T_CONTAINER,    // 可视化组件组, 容器
    T_UI,           // 界面组件, 高级容器
    T_EFFECT,       // 效果组件, 使实现某种效果
    T_PROCESSOR     // 处理器组件, 用于处理数据
} CLASS_TYPE;

// 用于查询Ui的常量
typedef enum
{
    UI_NONE,
    UI_MAIN,
    UI_SINGER,
    UI_CATALOGRY,
    UI_LANGUAGE,
    UI_RANK,
    UI_POP,
    UI_LYRICS,
    UI_PINYIN,
    UI_SONGS,
    UI_BOTTOMTUTTONS,
    UI_MAX
} which_ui_t;

typedef enum
{
    INC_PICKING_NAME,
    INC_SQL_EVENT_ID,
    INC_TEXTURE_EVENT_ID,
    INC_TEXTURE_RANGE_ID,
    INC_DEBUG,
    INC_DEBUG2,
    INC_MAX,
    INC_RESET_ALL = INC_MAX
} WHICH_INCREAMENT;

typedef enum
{
    TIMER1,
    TIMER2,
    TIMER_MAX
} WHICH_TIMER;

struct GLcolor4
{
    GLfloat red;
    GLfloat green;
    GLfloat blue;
    GLfloat alpha;
};

#include <vector>
#include <string>



// platform defineitions
#ifdef UNDER_CE
#define GET_FONT_PATH(font_name) "\\NAND\\fonts\\" ##font_name
#else
#define GET_FONT_PATH(font_name) ".\\fonts\\" ##font_name
#endif

// types definition
typedef std::vector<VWidget*> VWidgetArray;
typedef bool(*mouse_event_t)(int x, int y, VWidget* sender);
typedef int (SDLCALL* thread_callback_t)(void*);

//#define KEY_DOWN(vk_code)   ((GetAsyncKeyState(vk_code) & 0x8000) ? 1 : 0)

//随机坐标
#define RAND_COORD(x)       ((float)rand()/RAND_MAX * (x))
#define FRAND               (((float)rand()-(float)rand())/RAND_MAX)

#define MAP_W               32
#define MAP_SCALE           24.0f
#define MAP                 (MAP_W*MAP_SCALE/2)

#define PI          (3.14159265359f)
#define DEG2RAD(a)  (PI/180*(a))
#define RAD2DEG(a)  (180/PI*(a))


#ifdef DEBUG
#ifndef ASSERT
#include <assert.h>
#define ASSERT(exp) do { assert(exp); } while (0)
#endif  // ASSERT
#else   // DEBUG
#define ASSERT(exp) do ; while(0)
#endif  // DEBUG


#ifndef UNUSED
#define UNUSED(x) (x)
#endif

#ifndef SAFE_RELEASE
#define SAFE_RELEASE(_pointer) do { if (_pointer != NULL) {delete _pointer; _pointer = NULL;} } while (0)
#endif

#ifndef CLICK_EVENT_CAST
#define CLICK_EVENT_CAST(func_ptr)\
    reinterpret_cast<mouse_event_t>(func_ptr)
#endif

#ifndef IMPLEMENT_GETTHIS
#define IMPLEMENT_GETTHIS(class_name) \
    protected:\
    static class_name* _pthis;\
    public:\
    static class_name* getThis() { return _pthis; };\
    protected:

#define DEFINE_THIS(class_name) \
    class_name* class_name::_pthis = NULL;

#define SET_THIS()\
    do { _pthis = this; } while (0)
#endif // IMPLEMENT_GETTHIS

#ifndef DISALLOW_ASSIGN_AND_COPY
#define DISALLOW_ASSIGN_AND_COPY(class_name)\
    class_name(const class_name&);\
    class_name& operator= (const class_name&);
#endif // DISALLOW_ASSIGN_AND_COPY
